<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>物流信息</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/H5/css/sm.min.css?v=10" />
    <link rel="stylesheet" type="text/css" href="/H5/css/reset.css?v=10" />
    <link rel="stylesheet" type="text/css" href="/H5/css/order.css?v=11" />
    <style>
        .logistics{margin-top: 2rem;background-color:#fbfbfb;border-radius: .3rem;padding-top:.4rem; }
        .coco{display: flex;justify-content: space-around;background-color: #fbfbfb;height: 3rem;}
        .coco:last-child div.co_left>div{height: 100%;}
        .coco>div.co_left {width: 39%;position: relative;text-align: center;align-items: center;display: flex;font-size: .8rem;line-height: .9rem}
        .coco>div{border-bottom:1px solid #cacaca;font-size: .6rem;line-height: .7rem;align-items: center;display: flex}
        div.co_left>div{border:none;width:.6rem;height:103%;position: absolute;background-color: #fbfbfb;right:0;top:0;}
        div.co_left>div>div{width: .7rem;border:1.5px solid #f38b69;border-radius: 1rem;height: .7rem;position: absolute;left:.05rem;top:1.2rem;background-color: white;}
        div.co_left>div>div>div{    width: .4rem;background-color: #f38b69;height: .4rem;border-radius: 2rem;margin-top: .084rem;margin-left: .085rem;}
        div.co_left>span{width: 100%;padding-right: .6rem;box-sizing: border-box;color: #676767}
        div.co_left div span{display: inline-block;width: 1px;background-color: #f38b69;height: 100%;margin-left: .22rem;}
        div.co_left .right_span{margin-left: 3px;}
        .coco>div:last-child {width: 61%;padding-left:.5rem;color: #3a4d56 }

    </style>
</head>
<body>
<div class="page-group ms-controller" :controller="logistics">
    <div class="page page-current">
        <header class="bar bar-nav">
            <a class="icon icon-left pull-left" href="javascript:window.history.go(-1)"></a>
            <a class="icon icon-home pull-right" href="/H5"></a>
            <h1 class="title">物流信息</h1>
        </header>
        <div class="content visibility">
            <div class="card card_first card_first01">
                <div style="padding: .5rem .75rem;">订单号：{{@data.order_no}}</div>
                <div class="card-content" :for="el in @data.goods" style="border-bottom: 2px solid #fff">
                    <div class="card-content-inner" :on-click="@to(el.goods_id)">
                        <a><img :attr="{'src':el.list_cover}"/></a>
                        <div class="order_right" >
                            <p>{{el.title}}</p>
                            <h5>{{el.intro||""}}</h5>
                            <div class="jifen"><span :visible="el.give_point>0" style="color: #4cd964; border-color: #4cd964;">赠送积分+{{el.give_point||0}}</span><span :visible="el.deviation_point>0">抵扣积分-{{el.deviation_point||0}}</span><span :visible="el.contribution>0" style="color: #4cd964; border-color: #4cd964;">贡献+{{el.contribution}}</span></div>
                        </div>
                    </div>
                    <ul class="address_ul">
                        <li style="font-size: .7rem;line-height: 30px;height: 30px;">商品单价<span>￥{{el.is_rebuy?el.vip_price:el.sell_price||""}}</span></li>
                        <li style="font-size: .7rem;line-height: 30px;height: 30px;">购买数量<span>{{el.buy_num}}</span></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="logistics">
            <div class="coco">
                <div class="co_left">
                    <span>2019.02.28 20:13</span>
                    <div>
                        <span></span><span class="right_span"></span>
                        <div><div></div></div>
                    </div>
                </div>
                <div class="co_right">
                    [长沙星沙中转场]快件到达 【长沙星沙集散中心】
                </div>
            </div>
            <div class="coco">
                <div class="co_left">
                    <span>2019.02.28 00:57  星期四</span>
                    <div>
                        <span></span><span class="right_span"></span>
                        <div><div></div></div>
                    </div>
                </div>
                <div class="co_right">
                    [大六项目营业点]快件在【上海大六项目营业点】已装车,准备发往 【上海华新集散中心】</div>
            </div>
            <div class="coco">
                <div class="co_left">
                    <span>2019.02.28 00:57  星期四</span>
                    <div>
                        <span></span><span class="right_span"></span>
                        <div><div></div></div>
                    </div>
                </div>
                <div class="co_right">
                    [大六项目营业点]快件在【上海大六项目营业点】已装车,准备发往 【上海华新集散中心】</div>
            </div>
            <div class="coco">
                <div class="co_left">
                    <span>2019.03.01 08:24</span>
                    <div>
                        <span></span><span class="right_span"></span>
                        <div><div></div></div>
                    </div>
                </div>
                <div class="co_right">
                    [商业乐园速运营业点]快件交给舒志斌，正在派送途中（联系电话：15660224942）</div>
            </div>
        </div>

    </div>
</div>
<script type='text/javascript' src='/H5/js/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/avalon.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/simpleStorage.js' charset='utf-8'></script>
<script type='text/javascript' src='/H5/js/mall.js?v=10' charset='utf-8'></script>
<script>
    var logistics = avalon.define({
        $id: "logistics",
        data: {picture_urls:[]},
        list: [],
        address: {},
        money: 0,
        point: 0,
        dkpoint: 0,
        postage: 0,
        con: 0,
        count: 0,
        params: Mall.parseUrl( window.location.href ),
        phone: "",
        totalPoint: 0,
        show: false,
        ph: false,
        rp: 0,
        username: '',
        mobile: '',
        nickname: '',
        change: function( e ){
            if( e.target.checked ){
                if( e.target.name == "yqPay" ){
                    logistics.show = true;
                }
                else{
                    logistics.ph = true;
                    this.total();
                }
                $('.content').scrollTop( $('.content').height() );
            }
            else{
                if( e.target.name == "yqPay" ){
                    logistics.show = false;
                }
                else{
                    logistics.ph = false;
                    this.total();
                }
            }

        },
        hb:function( e ){
            if( this.totalPoint > this.money ){
                if( this.rp >  this.money ){
                    this.rp = this.money;
                }
            }
            else{
                if( this.rp >  this.totalPoint ){
                    this.rp = this.totalPoint;
                }
            }
            if( this.rp < 0 ){
                this.rp = 0;
            }
            this.total();
        },
        getAddress: function(){
            Mall.request( "/api/AddressList" )
                .always( function( data ){
                    if( data.error_code == 0 ){
                        if( logistics.params.addressId ){
                            for( var i = 0; i < data.data.length; i ++ ){
                                if( data.data[i].id == logistics.params.addressId  ){
                                    logistics.address = data.data[i];
                                    break;
                                }
                            }
                        }
                        else{
                            for(  var i = 0; i < data.data.length; i ++ ){
                                if( data.data[i].is_default == 1  ){
                                    logistics.address = data.data[i];
                                    break;
                                }
                            }
                        }
                        if( !logistics.address.id ){
                            logistics.address = data.data[0]
                        }
                        if(logistics.address.is_remote){
                            logistics.money = Number(logistics.money)+6;
                            document.getElementById('fee_p').style.display="block";
                        }
                    }
                } );
        },
        getDetail: function(){
            if( logistics.params.id.split(",").length > 1 ){
                Mall.request( "/api/ShopcartList" )
                    .always( function( data ){
                        if( data.error_code == 0 ){
                            var list = data.data.list,
                                ids = logistics.params.id.split(",");
                            for( var i = 0; i < ids.length; i ++ ){
                                for( var k = 0; k < list.length; k ++ ){
                                    if( ids[i] == list[k].goods_id ){
                                        logistics.list.push( list[k] );
                                    }
                                }
                            }
                            logistics.total();
                            if( logistics.totalPoint > logistics.money ){
                                logistics.rp = logistics.money;
                            }
                            else{
                                logistics.rp = logistics.totalPoint;
                            }
                            $( ".content" ).removeClass( "visibility" );
                        }
                    } )
            }
            else{
                Mall.request( "/api/GoodsDetail", {goods_id: logistics.params.id} )
                    .always( function( data ){
                        if( data.error_code == 0 ){
                            logistics.data = data.data;
                        }
                        logistics.total();
                        if( logistics.totalPoint > logistics.money ){
                            logistics.rp = logistics.money;
                        }
                        else{
                            logistics.rp = logistics.totalPoint;
                        }
                        $( ".content" ).removeClass( "visibility" );
                    } )
            }
        },
        total: function(){
            this.money = 0;
            this.con = 0;
            this.postage = 0;
            if( this.list.length ){
                for( var i = 0; i < this.list.length; i ++ ){
                    if( this.list[i].is_rebuy ){
                        this.money += this.list[i].vip_price*this.list[i].buy_num;
                    }
                    else{
                        this.money += this.list[i].sell_price*this.list[i].buy_num;
                    }
                    this.con += Math.abs(this.list[i].contribution)*this.list[i].buy_num;
                }
                if( this.money <= 100 ){
                    this.postage = 20;
                    this.money += this.postage;
                }
                else{
                    if( simpleStorage.get("postage") && this.money >= simpleStorage.get("postage") ){
                        this.postage = "包邮";
                    }
                    else{
                        this.postage = 10;
                        this.money += this.postage;
                    }
                }
            }
            else{
                this.count = Mall.parseUrl( window.location.href ).count||1;
                if( this.data.is_rebuy ){
                    this.money += this.data.vip_price*this.count;
                }
                else{
                    this.money += this.data.sell_price*this.count;
                }
                this.con = this.data.contribution*this.count;
                this.postage = Number( this.data.postage );
                this.money += this.postage;
            }
            if( $("input[name='usehp']").prop( "checked" ) ){
                this.money -= this.rp;
            }
        },
        submit: function(){
            if( Mall.LOCK ){
                return
            }
            if( !logistics.address ){
                $.toast( "请填写收货地址", 2000, "warning" )
                return
            }
            if( $( ".label-switch input:checked" ).attr( "name" ) != "yqPay" ){
                var postData = "address_id="+logistics.address.id;
                if( this.list.length ){
                    for( var i = 0; i < this.list.length; i ++ ){
                        postData += "&goods["+this.list[i].goods_id+"]="+this.list[i].buy_num
                    }
                }
                else{
                    postData += "&goods["+this.data.id+"]="+this.count
                }
                if(!$("input[name='usehp']").prop( "checked" )){
                    this.rp = 0;
                }
                postData += "&red_packets="+this.rp;
                //postData += "&mobile="+logistics.mobile;
                postData += "&phone="+logistics.phone;
                var url = "/api/OrderSubmitBalance";
                Mall.LOCK = true;
                $( "#submit" ).text( "提交中" );
                Mall.request( url, postData )
                    .always( function( data ){
                        if( data.error_code == 0 ){
                            window.history.replaceState(null,null,"/H5/pay?orderId="+data.data.order_no);
                            window.location.reload();
                        }
                        $( "#submit" ).text( "提交订单" );
                        Mall.LOCK = false;
                    } )
            }
            else{
                var postData = "address_id="+logistics.address.id+"&phone="+logistics.phone+"&mobile="+logistics.mobile;
                if( this.list.length ){
                    for( var i = 0; i < this.list.length; i ++ ){
                        postData += "&goods["+this.list[i].goods_id+"]="+this.list[i].buy_num
                    }
                }
                else{
                    postData += "&goods["+this.data.id+"]="+this.count;
                }
                if(!$("input[name='usehp']").prop( "checked" )){
                    this.rp = 0;
                }
                postData += "&red_packets="+this.rp;
                Mall.LOCK = true;
                $( "#submit" ).text( "提交中" );
                var url = "/api/OrderSubmitInvite";
                $.prompt("请输入支付密码", function( value ){
                    postData += "&pay_password="+value;
                    Mall.request( url, postData )
                        .always( function( data ){
                            if( data.error_code == 0 ){
                                simpleStorage.set( "df", undefined );
                                $.toast( "提交代付成功", 1000, "success", function(){
                                    window.location.href="/H5/friendlist?type=2";
                                } )
                            }
                            Mall.LOCK = false;
                        } )
                })
                $( "input.modal-text-input" ).attr( "type", "password" )
            }
        },
        getInfo: function(){
            Mall.request("/api/UserInfo")
                .always(function(data){
                    if( data.error_code == 0 ){
                        logistics.totalPoint = data.data.red_packets;
                        logistics.phone = data.data.mobile;
                        logistics.username = data.data.username;
                        logistics.nickname = data.data.nickname;
                        if(logistics.phone != ''){
                            $("#mobile").attr("readOnly","true");
                        }
                    }
                })
        }
    })
    logistics.getInfo();
    logistics.getDetail();
    logistics.getAddress();
    window.onbeforeunload = function(){
        console.log( a )
        return
    };
    window.onunload = function( a ){
        console.log( a )
        return
    };
    if(logistics.mobile != ''){
        $("#mobile").attr("readOnly","true");
    }
    avalon.scan( document.body );
</script>
</body>
</html>